package unimelb.filesync.server.protocol;

import java.net.ServerSocket;

import unimelb.filesync.common.misc.ProtocolContext;
import unimelb.filesync.common.network.NetworkConnection;
import unimelb.filesync.common.network.NetworkService;
import unimelb.filesync.common.protocol.IFileSyncPhase;
import unimelb.filesync.common.protocol.PrepareFileSync;

public class PrepareServerFileSync extends PrepareFileSync implements IFileSyncPhase {

    private final NetworkService networkService;

    public PrepareServerFileSync(ProtocolContext context) {
        super(context);
        this.networkService = new NetworkService();
    }

    @Override
    protected NetworkConnection createConnection() {
        final ServerSocket serverSocket = context.getObject(ProtocolContext.SERVER_SOCKET);
        return networkService.acceptConenction(serverSocket);
    }

}
